Refactor semantic id handler to saperate the logic#78
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Refactors SemanticIdHandler into a small facade delegating to a semantic tree extractor and a submodel filler, with per–submodel-element-type handlers and shared helper utilities, to reduce complexity and improve maintainability of semantic-id extraction/fill-out logic.
Changes:
- Introduced
SemanticIdsubsystem (Extraction,FillOut,ElementHandlers,Helpers) and rewired DI to register these services/handlers. - Replaced the monolithic
SemanticIdHandlerimplementation with delegation toISemanticTreeExtractor+ISubmodelFiller. - Added/updated unit tests for helpers, extractor/filler, and element handlers; adjusted existing tests accordingly.
Reviewed changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| source/AAS.TwinEngine.DataEngine/ServiceConfiguration/ApplicationDependencyInjectionExtensions.cs | Registers new semantic-id services/helpers/handlers in DI. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs | Minor refactor around template fill-out call (plus new import). |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandler.cs | Replaces monolithic logic with extractor+filler delegation. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelper.cs | Adds submodel element cloning/path navigation/language resolution helper. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigator.cs | Centralizes semantic-tree traversal utilities. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolver.cs | Centralizes semantic-id/cardinality/value-type resolution logic. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelper.cs | Extracts/populates model reference keys via semantic tree nodes. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISubmodelElementHelper.cs | Interface for element helper functions. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISemanticIdResolver.cs | Interface for semantic id resolver. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/IReferenceHelper.cs | Interface for reference helper behavior. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFiller.cs | New fill-out engine that delegates element fill-out to type handlers. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/ISubmodelFiller.cs | Interface for submodel filling. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractor.cs | New extractor that delegates element extraction to type handlers. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/ISemanticTreeExtractor.cs | Interface for semantic tree extraction. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandler.cs | Handles relationship element extraction/fill-out via reference helper. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandler.cs | Handles reference element extraction/fill-out via reference helper. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandler.cs | Handles range extraction/fill-out (min/max leaves). |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandler.cs | Handles property extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandler.cs | Handles MLP extraction/fill-out with language resolution. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandler.cs | Handles submodel element list extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ISubmodelElementTypeHandler.cs | Defines element handler contract (extract + fill-out). |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandler.cs | Handles file extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandler.cs | Handles entity extraction/fill-out (incl. self-managed fields). |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandler.cs | Handles collection extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandler.cs | Handles blob extraction/fill-out (base64 decode). |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRegistry/ShellDescriptorService.cs | Minor catch-block cleanup. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/TestData.cs | Adjusts shared test data (specific asset ids naming/init). |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandlerTests.cs | Updates tests to use new extractor/filler architecture. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelperTests.cs | Adds unit tests for SubmodelElementHelper. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigatorTests.cs | Adds unit tests for semantic-tree navigation helpers. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolverTests.cs | Adds unit tests for semantic id resolver behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelperTests.cs | Adds unit tests for reference extraction/population. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFillerTests.cs | Adds unit tests for submodel filler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractorTests.cs | Adds unit tests for semantic tree extractor behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandlerTests.cs | Adds unit tests for relationship handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandlerTests.cs | Adds unit tests for reference handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandlerTests.cs | Adds unit tests for range handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandlerTests.cs | Adds unit tests for property handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandlerTests.cs | Adds unit tests for MLP handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandlerTests.cs | Adds unit tests for list handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandlerTests.cs | Adds unit tests for file handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandlerTests.cs | Adds unit tests for entity handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandlerTests.cs | Adds unit tests for collection handler behavior. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandlerTests.cs | Adds unit tests for blob handler behavior. |
| source/AAS.TwinEngine.DataEngine.ModuleTests/Api/Services/SubmodelRepository/SubmodelRepositoryControllerTests.cs | Minor test cleanup (discarding return values). |
| example/docker-compose.yml | Changes DataEngine image reference used by the example stack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandler.cs
Show resolved
Hide resolved
...nEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR refactors SemanticId handling by splitting the previously monolithic SemanticIdHandler into focused components (resolver/helpers, per-element handlers, extractor, and filler), and wires the new services through dependency injection with corresponding unit/module test updates.
Changes:
- Introduced dedicated
ISubmodelElementTypeHandlerimplementations plus new helper/resolver utilities to handle extraction and fill-out logic per submodel element type. - Replaced
SemanticIdHandler’s internal logic with delegation toISemanticTreeExtractorandISubmodelFiller. - Updated DI registrations and extended/adjusted unit + module tests to cover the refactor.
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| source/AAS.TwinEngine.DataEngine/ServiceConfiguration/ApplicationDependencyInjectionExtensions.cs | Registers new SemanticId extractor/filler/helpers and element handlers in DI. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs | Minor refactor around returning filled submodel. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandler.cs | Delegates semantic-id operations to extractor/filler. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelper.cs | Adds cloning, idShort navigation, and language resolution utilities. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigator.cs | Centralizes semantic tree traversal helpers. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolver.cs | Centralizes semantic-id resolution, cardinality, and datatype inference. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelper.cs | Extracts/populates reference keys and relationship references. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISubmodelElementHelper.cs | Interface for submodel element helper utilities. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISemanticIdResolver.cs | Interface for semantic-id resolution operations. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/IReferenceHelper.cs | Interface for reference extraction/population logic. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFiller.cs | Implements template fill-out using element handlers. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/ISubmodelFiller.cs | Interface for submodel fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractor.cs | Implements semantic tree extraction using element handlers. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/ISemanticTreeExtractor.cs | Interface for semantic tree extraction. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandler.cs | Handler for relationship element extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandler.cs | Handler for reference element extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandler.cs | Handler for range extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandler.cs | Handler for property extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandler.cs | Handler for multi-language property extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandler.cs | Handler for submodel element list extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ISubmodelElementTypeHandler.cs | Defines the handler contract for element types. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandler.cs | Handler for file extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandler.cs | Handler for entity extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandler.cs | Handler for collection extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandler.cs | Handler for blob extraction/fill-out. |
| source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRegistry/ShellDescriptorService.cs | Removes unused exception variable in catch block. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/TestData.cs | Updates shared test data for entity specific asset ids. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandlerTests.cs | Updates SemanticIdHandler tests to use new components/handlers. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelperTests.cs | Adds unit tests for SubmodelElementHelper. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigatorTests.cs | Adds unit tests for SemanticTreeNavigator. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolverTests.cs | Adds unit tests for SemanticIdResolver. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelperTests.cs | Adds unit tests for ReferenceHelper. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFillerTests.cs | Adds unit tests for SubmodelFiller. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractorTests.cs | Adds unit tests for SemanticTreeExtractor. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandlerTests.cs | Adds unit tests for RelationshipElementHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandlerTests.cs | Adds unit tests for ReferenceElementHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandlerTests.cs | Adds unit tests for RangeHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandlerTests.cs | Adds unit tests for PropertyHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandlerTests.cs | Adds unit tests for MultiLanguagePropertyHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandlerTests.cs | Adds unit tests for ListHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandlerTests.cs | Adds unit tests for FileHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandlerTests.cs | Adds unit tests for EntityHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandlerTests.cs | Adds unit tests for CollectionHandler. |
| source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandlerTests.cs | Adds unit tests for BlobHandler. |
| source/AAS.TwinEngine.DataEngine.ModuleTests/Api/Services/SubmodelRepository/SubmodelRepositoryControllerTests.cs | Minor test adjustments to discard unused return values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
...nEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs
Outdated
Show resolved
Hide resolved
.../ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractor.cs
Show resolved
Hide resolved
...AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/TestData.cs
Show resolved
Hide resolved
...onLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandler.cs
Outdated
Show resolved
Hide resolved
This reverts commit dd01f18.
|
Test & Coverage ReportTest Results Summary
Code CoverageUnit Tests Coverage
Minimum allowed line rate is Module Tests Coverage
|



Restructured the SemanticId handling logic by introducing dedicated handlers for each submodel element, reducing complexity and improving readability.